<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 1.class类
        class Person {
            static eye = 2; // 静态属性
            constructor(name, age) {
                this.name = name
                this.age = age
            }
            say() {
                console.log('你好我是类')
            }
            static run() {
                console.log('我再跑步')
            }
            this() {
                console.log(this)
            }
        }
        // 调用属性/方法
        // 静态成员调用 - 类调用
        console.log(Person.eye)
        Person.run()
        // Person.say()  // 会报错

        // 实例化
        var Per = new Person('胖鸡', 20)
        console.log(Per)
        Per.say()
        Per.this()


        // 2.继承
        class Dad {
            constructor (name,age){
                this.name = name
                this.age = age
            }
            say(){
                console.log(this.name + '我是继承dad父类')
            }
        }

        class Son extends Dad {
            constructor (sex, name, age){
                // 必须调用父级(在使用extends时)
                super(name,age)
                this.sex =sex
            }
            run () {
                console.log('儿子会跑')
            }
        }

        var son = new Son('男','胖鸡',22)
        console.log('我是儿子' , son)
        son.say()
        son.run()

    </script>

</body>

</html>